From: Florian Müllner Date: Thu, 27 Nov 2014 19:46:50 +0000 (+0100) Subject: gestures: Restrict actions based on keybindingMode X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~1934 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=ddeac2386f2d6dde4a87d9043850017248797a6e;p=gnome-shell.git gestures: Restrict actions based on keybindingMode Just like keybindings and the message tray pointer barrier, gestures don't always make sense - for instance, swiping up the screen shield should not trigger the message tray just as the SelectArea action around the left edge should not open the overview. To avoid this, restrict gestures based on the current keybinding mode. https://bugzilla.gnome.org/show_bug.cgi?id=740237 --- diff --git a/js/ui/edgeDragAction.js b/js/ui/edgeDragAction.js index 692da4146..46e96d7a9 100644 --- a/js/ui/edgeDragAction.js +++ b/js/ui/edgeDragAction.js @@ -6,6 +6,8 @@ const Meta = imports.gi.Meta; const Clutter = imports.gi.Clutter; const St = imports.gi.St; +const Main = imports.ui.main; + const EDGE_THRESHOLD = 20; const DRAG_DISTANCE = 80; @@ -13,9 +15,10 @@ const EdgeDragAction = new Lang.Class({ Name: 'EdgeDragAction', Extends: Clutter.GestureAction, - _init : function(side) { + _init : function(side, allowedModes) { this.parent(); this._side = side; + this._allowedModes = allowedModes; this.set_n_touch_points(1); global.display.connect('grab-op-begin', Lang.bind(this, function() { @@ -34,6 +37,9 @@ const EdgeDragAction = new Lang.Class({ if (this.get_n_current_points() == 0) return false; + if (!(this._allowedModes & Main.keybindingMode)) + return false; + let [x, y] = this.get_press_coords(0); let monitorRect = this._getMonitorRect(x, y); diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js index ad7c5c886..a034fc399 100644 --- a/js/ui/messageTray.js +++ b/js/ui/messageTray.js @@ -1951,7 +1951,9 @@ const MessageTray = new Lang.Class({ this._messageTrayMenuButton.actor.connect('key-press-event', Lang.bind(this, this._onTrayButtonKeyPress)); - let gesture = new EdgeDragAction.EdgeDragAction(St.Side.BOTTOM); + let gesture = new EdgeDragAction.EdgeDragAction(St.Side.BOTTOM, + Shell.KeyBindingMode.NORMAL | + Shell.KeyBindingMode.OVERVIEW); gesture.connect('activated', Lang.bind(this, this.toggle)); global.stage.add_action(gesture); }, diff --git a/js/ui/viewSelector.js b/js/ui/viewSelector.js index d0e814096..57395e38c 100644 --- a/js/ui/viewSelector.js +++ b/js/ui/viewSelector.js @@ -65,7 +65,8 @@ const ShowOverviewAction = new Lang.Class({ }, vfunc_gesture_prepare : function(action, actor) { - return this.get_n_current_points() == this.get_n_touch_points(); + return Main.keybindingMode == Shell.KeyBindingMode.NORMAL && + this.get_n_current_points() == this.get_n_touch_points(); }, _getBoundingRect : function(motion) { @@ -215,7 +216,8 @@ const ViewSelector = new Lang.Class({ let gesture; - gesture = new EdgeDragAction.EdgeDragAction(St.Side.LEFT); + gesture = new EdgeDragAction.EdgeDragAction(St.Side.LEFT, + Shell.KeyBindingMode.NORMAL); gesture.connect('activated', Lang.bind(this, function() { if (Main.overview.visible) Main.overview.hide(); diff --git a/js/ui/windowManager.js b/js/ui/windowManager.js index 60ab30f7a..e3325527e 100644 --- a/js/ui/windowManager.js +++ b/js/ui/windowManager.js @@ -478,7 +478,9 @@ const WorkspaceSwitchAction = new Lang.Class({ }, vfunc_gesture_prepare : function(action, actor) { - return this.get_n_current_points() == this.get_n_touch_points(); + let allowedModes = Shell.KeyBindingMode.NORMAL | Shell.KeyBindingMode.OVERVIEW; + return this.get_n_current_points() == this.get_n_touch_points() && + (allowedModes & Main.keybindingMode); }, vfunc_gesture_end : function(action, actor) { @@ -526,7 +528,7 @@ const AppSwitchAction = new Lang.Class({ }, vfunc_gesture_prepare : function(action, actor) { - if (Main.overview.visible) { + if (Main.keybindingMode != Shell.KeyBindingMode.NORMAL) { this.cancel(); return false; }